package com.hxgis.statisticanalysis.common.config;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;

/**
 * 所属公司： 华信联创技术工程有限公司
 * 版本： 1.0
 * 创建人： 罗佳星
 * 创建时间：2017-11-08 11:19
 */
@ApiModel("返回数据")
public class ResponseData<T> {

    @ApiModelProperty(value = "接口状态")
    private Integer code;

    @ApiModelProperty(value = "接口状态描述", position = 1)
    private String message;

    @ApiModelProperty(value = "数据开始时间", position = 2)
    private Long startTime;

    @ApiModelProperty(value = "数据结束时间", position = 3)
    private Long endTime;

    @ApiModelProperty(value = "数据条数", position = 4)
    private Integer count;

    @ApiModelProperty(value = "数据主体", position = 5)
    private T data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Long getStartTime() {
        return startTime;
    }

    public void setStartTime(Long startTime) {
        this.startTime = startTime;
    }

    public Long getEndTime() {
        return endTime;
    }

    public void setEndTime(Long endTime) {
        this.endTime = endTime;
    }

    public int getCount() {
        if (data != null && data instanceof List) {
            count = ((List) data).size();
        } else {
            count = 1;
        }
        return count;
    }
}
